/**
 * ReportGear(2011)
 */
package com.reportgear.report.model.script.function;

import java.util.ArrayList;
import java.util.List;

import net.abbp.core.util.NumberUtils;
import com.reportgear.report.model.script.function.Function.Type;

/**
 * 
 * 
 * @version 1.0 2011-4-10
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class ToList extends AbstractFunction {
	@Override
	public Object exec(Object[] args) {
		int from = NumberUtils.convertToInteger(args[0], 0);
		int to = NumberUtils.convertToInteger(args[1], 0);

		List<Integer> list = new ArrayList<Integer>();

		for (int i = from; i <= to; i++) {
			list.add(i);
		}

		return list;
	}

	@Override
	public Type getType() {
		return Type.ARRAY;
	}
}
